package unittest;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import treeedit.BZAddressParser;
import treeedit.TedAlgorithm;
import treeedit.Tree;

public class TedAlgorithmTest_lmld {

	int[] result = new int[] { 0, 1, 2, 2, 1, 5, 1 };

	@Test
	public void testLmld() {

		// =============Initialize================

		Tree tree1 = createDumpT1();
		tree1.init();
		// Get array of Leftmost leaf descendants of tree1
		int[] l1 = TedAlgorithm.lmld(tree1);

		// ==========TEST=======
		assertEquals("Result", result[0], l1[0]);
		assertEquals("Result", result[1], l1[1]);
		assertEquals("Result", result[2], l1[2]);
		assertEquals("Result", result[3], l1[3]);
		assertEquals("Result", result[4], l1[4]);
		assertEquals("Result", result[5], l1[5]);
		assertEquals("Result", result[6], l1[6]);

	}
	
	static Tree createDumpT1() {
		Tree f = new Tree("f");
		Tree d = f.addChild(new Tree("d"));
		d.addChild(new Tree("a"));
		Tree c = d.addChild(new Tree("c"));
		c.addChild(new Tree("b"));
		f.addChild(new Tree("e"));
		return f;
	}

}
